package com.example.samchat;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;

public class UploadThread extends Thread{
	private String addr;
	private ChattingDto dto;
	private String msg;
	public UploadThread(String addr,String msg,ChattingDto dto){
		this.addr = addr;
		this.msg = msg;
		this.dto = dto;
	}
	
	public void run(){
		HttpPost post = new HttpPost(addr);
		HttpClient client = new DefaultHttpClient();
		
		try{
			List params = new ArrayList();
			params.add(new BasicNameValuePair("test", msg));
			
			HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
			
			UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params);
			
			post.setEntity(ent);
			
			client.execute(post);
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}